<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 61741
  Date: 2018/1/21
  Time: 15:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册</title>
    <meta charset="utf-8">
    <jsp:include page="../common/portal-head.jsp"></jsp:include>
    <%--<jsp:include page="../common/header.jsp"></jsp:include>--%>
    <%--<jsp:include page="../common/cloud-head.jsp"></jsp:include>--%>

    <link rel="stylesheet" type="text/css" href="${ctx}/resources/portal/css/app.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/portal/css/regist.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/portal/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/portal/css/upimg.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/portal/css/app.css">
    <script src="${ctx}/resources/script/common.js" type="text/javascript"></script>\
    <style>
        section.z_file.fl input {
            display: block !important;
            background: #333;
            width: 100% !important;
            height: 100% !important;
        }
    </style>
</head>
<body>
<div class="page-container">
    <form action="${ctx}/register/register" id="register-form" method="post" >
        <div class="content">
            <div class="part1-outline">
                <div class="regist-pat1">
                    <div class="logo" onclick="javascript:window.location.href='http://www.neiyibaba.cn/'">
                        <img src="${ctx}/resources/portal/img/banner/c-logo.png">
                    </div>
                    <div class="user">
                        <span>手机号<strong>*</strong></span>
                        <input type="text" name="phone" id="phone">
                    </div>
                    <div class="pass">
                        <span>短信验证码<strong>*</strong></span>
                        <input type="text" name="vrcd" placeholder="短信验证码">
                        <a href="javascript:sendSms();" id="sendBtn">获取验证码</a>
                    </div>
                    <div class="user-kind">
                        <span>用户类别</span>
                        <select id="user-select" name="userType">
                            <option value="">-请选择-</option>
                            <option value="2">厂商</option>
                            <option value="3">代理商</option>
                            <option value="4">辅助料配件商</option>
                            <option value="5">物流公司</option>
                        </select>
                    </div>
                    <div class="address">
                        <div class="add-city">
                            <span>地址<strong>*</strong></span>
                            <select id="seachprov" name="province"
                                    onChange="changeComplexProvince(this.value);">
                                <option value="">请选择</option>
                                <c:forEach items="${province}" var="province">
                                    <option value="${province.addressId}">${province.name}</option>
                                </c:forEach>
                            </select>&nbsp;&nbsp;
                            <select id="seachcity" name="city"
                                    onChange="changeCity(this.value);">
                                <option value="">请选择</option>
                            </select>&nbsp;&nbsp;
                            <select id="seachdistrict" name="town">
                                  <option value="">请选择</option>
                            </select>
                            <input type="text" placeholder="详细地址" id="detailadd-input" name="detailAdd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="regist-pat2">
                <div class="company-name">
                    <span>公司名称<strong>*</strong></span>
                    <input type="text" name="companyName" id="companyname-input">
                </div>
                <div class="company-name">
                    <span>公司简称<strong>*</strong></span>
                    <input type="text" name="stName" id="shortname-input">
                </div>
                <div class="contact">
                    <span>联系方式</span>
                    <select id="contact">
                        <option>手机</option>
                        <option>座机</option>
                        <option>邮箱</option>
                    </select>
                    <input type="text" name="userContact" id="contact-input">
                </div>
                <div class="company-dsc">
                    <span> 公司简介<strong>*</strong></span>
                    <textarea name="userDsc" id="companyDesc"></textarea>
                </div>
                <div class="owner-name">
                    <span>法人姓名<strong>*</strong></span>
                    <input type="text" name="chairtMan" id="ownername-input">
                </div>
                <div class="owner-name">
                    <span>身份证号<strong>*</strong></span>
                    <input type="text" name="idCard" id="idCard-input">
                </div>
                <div class="cert-Card">
                    <span>银行卡号<strong>*</strong></span>
                    <input type="text" name="certCard" id="certcard-input">
                </div>
                <div class="cert-Card">
                    <span>开户行<strong>*</strong></span>
                    <input type="text" name="openBank" id="bankadd-input">
                </div>
                <div class="company-logo">
                    <span>公司logo<strong>*</strong></span>
                    <div class="form-group">
                        <img id="img-preview1" name="img-preview" class="img_upload_preview"
                             for="logoimg-file" data-target="img-val" src=""
                             onclick="$('#logoimg-file').click()"
                             onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>
                        <input id="logoimg-file" type="file" name="logoimg-file" style="display: none;"
                               onchange="uploadFile('logoimg-file','img-preview1','logo_img','image')"/>
                        <input name="logo_img" id="logo_img" type="hidden">
                    </div>
                    <div class='alert alert-warning' id="picsize"><span>建议大小:226px*110px</span></div>
                </div>
                <div class="company-logo">
                    <span>营业执照<strong>*</strong></span>
                    <div class="form-group">
                        <img id="img-preview2" name="img-preview" class="img_upload_preview"
                             for="lienceimg-file" data-target="img-val" src=""
                             onclick="$('#lienceimg-file').click()"
                             onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>
                        <input id="lienceimg-file" type="file" name="img-file" style="display: none;"
                               onchange="uploadFile('lienceimg-file','img-preview2','busListenerPic','image')"/>
                        <input name="busListenerPic" id="busListenerPic" type="hidden">
                    </div>
                </div>
                <div class="company-logo">
                    <span>身份证正反面<strong>*</strong></span>
                    <div class="form-group">
                        <img id="img-preview3" name="img-preview" class="img_upload_preview"
                             for="idCardImg1-file" data-target="img-val" src=""
                             onclick="$('#idCardImg1-file').click()"
                             onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>
                        <input id="idCardImg1-file" type="file" name="img-file" style="display: none;"
                               onchange="uploadFile('idCardImg1-file','img-preview3','idCardImg1','image')"/>
                        <input name="idCardImg1" id="idCardImg1" type="hidden">
                    </div>
                    <div class="form-group">
                        <img id="img-preview4" name="img-preview" class="img_upload_preview"
                             for="idCardImg2-file" data-target="img-val" src=""
                             onclick="$('#idCardImg2-file').click()"
                             onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>
                        <input id="idCardImg2-file" type="file" name="img-file" style="display: none;"
                               onchange="uploadFile('idCardImg2-file','img-preview4','idCardImg2','image')"/>
                        <input name="idCardImg2" id="idCardImg2" type="hidden">
                    </div>
                </div>
                <div class="company-logo">
                    <span>公司相关照片<strong>*</strong></span>
                    <div class="companypic-group">
                        <img id="img-preview5" name="img-preview" class="img_upload_preview"
                             for="companyPics1-file" data-target="img-val" src=""
                             onclick="$('#companyPics1-file').click()"
                             onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>
                        <input id="companyPics1-file" type="file" name="img-file" style="display: none;"
                               onchange="uploadFile('companyPics1-file','img-preview5','companyPics1','image')"/>
                        <input name="companyPics1" id="companyPics1" type="hidden">
                        <div class='alert alert-warning' id="picsize"><span>公司宣传封面:建议大小:1170px*180px</span></div>
                    </div>
                    <%--<div class="companypic-group">--%>
                        <%--<img id="img-preview6" name="img-preview" class="img_upload_preview"--%>
                             <%--for="companyPics2-file" data-target="img-val" src=""--%>
                             <%--onclick="$('#companyPics2-file').click()"--%>
                             <%--onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>--%>
                        <%--<input id="companyPics2-file" type="file" name="img-file" style="display: none;"--%>
                               <%--onchange="uploadFile('companyPics2-file','img-preview6','companyPics2','image')"/>--%>
                        <%--<input name="companyPics2" id="companyPics2" type="hidden">--%>
                        <%--<div class='alert alert-warning' id="picsize"><span>公司场景图片：建议大小:220px*220px</span></div>--%>
                    <%--</div>--%>
                    <%--<div class="companypic-group">--%>
                        <%--<img id="img-preview7" name="img-preview" class="img_upload_preview"--%>
                             <%--for="companyPics3-file" data-target="img-val" src=""--%>
                             <%--onclick="$('#companyPics3-file').click()"--%>
                             <%--onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>--%>
                        <%--<input id="companyPics3-file" type="file" name="img-file" style="display: none;"--%>
                               <%--onchange="uploadFile('companyPics3-file','img-preview7','companyPics3','image')"/>--%>
                        <%--<input name="companyPics3" id="companyPics3" type="hidden">--%>
                        <%--<div class='alert alert-warning' id="picsize"><span>公司场景图片：建议大小:220px*220px</span></div>--%>
                    <%--</div>--%>
                    <%--<div class="companypic-group">--%>
                        <%--<img id="img-preview8" name="img-preview" class="img_upload_preview"--%>
                             <%--for="companyPics4-file" data-target="img-val" src=""--%>
                             <%--onclick="$('#companyPics4-file').click()"--%>
                             <%--onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>--%>
                        <%--<input id="companyPics4-file" type="file" name="img-file" style="display: none;"--%>
                               <%--onchange="uploadFile('companyPics4-file','img-preview8','companyPics4','image')"/>--%>
                        <%--<input name="companyPics4" id="companyPics4" type="hidden">--%>
                        <%--<div class='alert alert-warning' id="picsize"><span>公司场景图片：建议大小:220px*220px</span></div>--%>
                    <%--</div>--%>
                </div>
                <div class="regist-button">
                    <a href="javascript:checkForm();">注册</a>
                </div>
            </div>
        </div>
    </form>
</div>
<script src="${ctx}/resources/portal/script/imgUp.js" type="text/javascript"></script>
</body>
<script>

    function registerSub() {
        var data = $('#register-form').serializeJson();
        asyncAjax({
            url: ctx + "/register/register",
            dataType:"json",
            contentType: "application/json",
            data: JSON.stringify(data),
            success: function (res) {
                if (res["result"] == "0") {
                    bootbox.confirm({
                        title: "资料已提交",
                        message: "资料已提交,系统将进行资料审核!",
                        buttons: {
                            confirm: {label: "确定"}
                        },
                        callback: function () {
                            window.location.href = "http://www.neiyibaba.cn/";
                        }
                    })
                }
                else {
                    bootbox.alert(res["msg"]);
                }
            }

        })

    }
    function checkForm() {
        if (isEmpty($("#phone").val())) {
            alert("请输入手机号!");
            return false;
        }
        else if (isEmpty($("#user-select").val())) {
                alert("请选择用户类别!");
                return false;
            }

          else  if (isEmpty($("#seachprov").val())) {
                alert("选择省份!");
                return false;
            }
        else  if (isEmpty($("#seachcity").val())) {
            alert("选择城市!");
            return false;
        }
        else  if (isEmpty($("#seachcity").val())) {
            alert("选择县市!");
            return false;
        }
        else  if (isEmpty($("#seachdistrict").val())) {
            alert("选择县市!");
            return false;
        }

        else  if (isEmpty($("#detailadd-input").val())) {
            alert("请输入详细地址!");
            return false;
        }
        else  if (isEmpty($("#companyname-input").val())) {
            alert("请输入公司名称!");
            return false;
        }
        else  if (isEmpty($("#contact-input").val())) {
            alert("请输入联系方式!");
            return false;
        }
        else  if (isEmpty($("#companyDesc").val())) {
            alert("请输入公司简介!");
            return false;
        }

        else  if (isEmpty($("#ownername-input").val())) {
            alert("请输入法人姓名!!");
            return false;
        }
        else  if (isEmpty($("#idCard-input").val())) {
            alert("请输入身份证号!");
            return false;
        }
        else  if (isEmpty($("#certcard-input").val())) {
            alert("请输入银行卡号!");
            return false;
        }
        else  if (isEmpty($("#bankadd-input").val())) {
            alert("请输入开户行地址!");
            return false;
        }
        else  if (isEmpty($("#logo_img").val())) {
            alert("请上传logo图片!");
            return false;
        }

        else  if (isEmpty($("#busListenerPic").val())) {
            alert("请上传营业执照!");
            return false;
        }
        else  if (isEmpty($("#idCardImg1").val())||isEmpty($("#idCardImg2").val())){
            alert("请上传身份证正反面图片!");
            return false;
        }
        else  if (isEmpty($("#companyPics1").val())||isEmpty($("#companyPics2").val())||isEmpty($("#companyPics3").val())||isEmpty($("#companyPics4").val())) {
            alert("请上传公司场景图片!");
            return false;
        }
        registerSub();

    }
    function sendSms() {
        var phone = $("#phone").val();
        if (/^1[3|4|5|7|8][0-9]{9}$/.test(phone) == false) {
            alert("请输入合法的手机号码!");
            return;
        }
        var data = {
            phone: phone,
            action: "REGISTER_VERIFY"
        }

        asyncAjax({
            url: ctx + "/sms/send",
            data: data,
            success: function (res) {
                if (res["result"] == 0) {
                    alert("验证码已经发送，请注意查收！");
                    $("#sendBtn").val("60s后重新发送").removeAttr("onclick").removeClass("login-submit");
                    var count = 60;
                    var timeInterval = window.setInterval(function () {
                        $("#sendBtn").val(--count + "后重新发送");
                    }, 1000)
                    setTimeout(function () {
                        $("#sendBtn").val("短信验证码").attr("onclick", "sendSms()").addClass("login-submit");
                        window.clearInterval(timeInterval);
                    }, 60000)
                } else {
                    alert(res["msg"]);
                }
            }
        })
    }
    function changeComplexProvince(provinceId) {
        var data ={provinceId:provinceId}
        asyncAjax({
            url: ctx + "/area/getAllcity?" + $.param(data).replace(/(%5D|%5B)/g, ""),
            beforeSend: function () {
                $("#seachcity").html('<option value="">请选择</option>');
                $("#seachdistrict").html('<option value="">请选择</option>');
            },
            success: function (res) {
                if (res["result"] == "0") {
                    if (!isEmpty(res["data"])) {
                        $.each(res["data"], function (idx, item) {
                            $("#seachcity").append('<option value=\"' + item["addressId"] + '\">' + item["shortName"] + '</option>')
                        })
                    } else {
                    }
                } else {
                    bootbox.alert(res["msg"]);
                }
            }
        })
        
    }
    function changeCity(cityId) {
        var data ={cityId:cityId}
        asyncAjax({
            url: ctx + "/area/getAllarea?" + $.param(data).replace(/(%5D|%5B)/g, ""),
            beforeSend: function () {
                $("#seachdistrict").html('<option value="">请选择</option>');
            },
            success: function (res) {
                if (res["result"] == "0") {
                    if (!isEmpty(res["data"])) {
                        $.each(res["data"], function (idx, item) {
                            $("#seachdistrict").append('<option value=\"' + item["addressId"] + '\">' + item["shortName"] + '</option>')
                        })
                    } else {
                    }
                } else {
                    bootbox.alert(res["msg"]);
                }
            }
        })

    }
</script>
</html>
